
using System;
using System.Collections.Generic;
using BTKERP.Model;
using BTKERP.DAL.DataAccess;
using System;

namespace BTKERP.DAL
{
	#region ProductRecipeUnitDAL
	public class ProductRecipeUnitDAL : DBContext
	{
		public List<ProductRecipeUnit> GetAll()
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_ProductRecipeUnitsSelectAll");
            return GetEntityList<ProductRecipeUnit>(cmd);
        }

        public List<ProductRecipeUnit> GetByProductId(Guid productId)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_ProductRecipeUnitSelect");
            cmd.AddParameter("@ProductId", productId);
            return GetEntityList<ProductRecipeUnit>(cmd);
        }

		public List<ProductRecipeUnit> GetByDynamicSQL(string sqlCondition)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_ProductRecipeUnitSelectDynamic");
            cmd.AddParameter("@SQL", sqlCondition);
            return GetEntityList<ProductRecipeUnit>(cmd);
        }

        public ProductRecipeUnit Add(Guid paramProductId, Guid paramUnitId, decimal paramNumberPerPackUnit, decimal paramShrinkage, string paramCreatedBy)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_ProductRecipeUnitUpdate");
            cmd.AddParameter("@ProductId", paramProductId);
            cmd.AddParameter("@UnitId", paramUnitId);
            cmd.AddParameter("@NumberPerPackUnit", paramNumberPerPackUnit);
            cmd.AddParameter("@Shrinkage", paramShrinkage);
            cmd.AddParameter("@CreatedBy", paramCreatedBy);
            return GetSingleEntity<ProductRecipeUnit>(cmd);
        }
		
        public bool DeleteById(Guid productId, Guid unitId)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_ProductRecipeUnitDelete");
            cmd.AddParameter("@ProductId", productId);
            cmd.AddParameter("@UnitId", unitId);
            return ExecuteCommand(cmd);
        }

        public ProductRecipeUnit UpdateById(Guid paramProductId, Guid paramUnitId,decimal paramNumberPerPackUnit,decimal paramShrinkage,string paramUpdatedBy)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_ProductRecipeUnitUpdate");
			cmd.AddParameter("@ProductId", paramProductId);
			cmd.AddParameter("@UnitId", paramUnitId);
			cmd.AddParameter("@NumberPerPackUnit", paramNumberPerPackUnit);
			cmd.AddParameter("@Shrinkage", paramShrinkage);
			cmd.AddParameter("@UpdatedBy", paramUpdatedBy);
            return GetSingleEntity<ProductRecipeUnit>(cmd);
        }
		
	}
	#endregion
}
